package com.sinog.biz.service.business.impl;

import com.sinog.biz.mapper.havexml.PrisaveTempMapper;
import com.sinog.biz.mapper.havexml.UploadAppendixFileMapper;
import com.sinog.biz.service.business.UploadAppendixFileFeignService;
import com.sinog.core.model.UploadAppendixFile;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @desc 上传文件实现类
 * @author -
 * @date -
 */
@Service
public class UploadAppendixFileFeignServiceImpl implements UploadAppendixFileFeignService {

    @Resource
    private UploadAppendixFileMapper uploadAppendixFileMapper;
    @Resource
    private PrisaveTempMapper prisaveTempMapper;

    /**
     * 将文件信息保存到mysql库中
     * @param uploadAppendixFile uploadAppendixFile
     * @return Integer
     */
    @Override
    public Integer saveAppendixFileData(UploadAppendixFile uploadAppendixFile) {
        return uploadAppendixFileMapper.insertFile(uploadAppendixFile);
    }

    /**
     * 从mysql库中查询出文件信息
     * @param pageIndex pageIndex
     * @param pageSize pageSize
     * @param map map
     * @return List<UploadAppendixFile>
     */
    @Override
    public List<UploadAppendixFile> selectAppendixFileData(Integer pageIndex,Integer pageSize,Map<String,Object> map) {
        Integer pageStart = pageIndex * pageSize;
        return uploadAppendixFileMapper.selectFileById(pageStart,pageSize,map);
    }

    /**
     * 查询文件数
     * @param map map
     * @return int
     */
    @Override
    public int count(Map<String,Object> map) {
        return uploadAppendixFileMapper.count(map);
    }

    /**
     * 根据id priNum taskId查询上传文件数量
     * @param map map
     * @return int
     */
    @Override
    public int getCountById(Map<String, Object> map) {
        return uploadAppendixFileMapper.getCountById(map);
    }

    /**
     * 根据id priNum taskId删除单个上传文件
     * @param map map
     * @return int
     */
    @Override
    public int deleteFileById(Map<String,Object> map){
        return uploadAppendixFileMapper.deleteFileById(map);
    }

    /**
     * 修改状态表
     * @param map map
     */
    @Override
    public void changeTemp(Map<String,Object> map) {
        prisaveTempMapper.updateTemp(map);
    }

    /**
     * 从mysql库中查找单个文件
     * @param uploadAppendixFile uploadAppendixFile
     * @return UploadAppendixFile
     */
    @Override
    public UploadAppendixFile findAppendixfileOne(UploadAppendixFile uploadAppendixFile) {
        return uploadAppendixFileMapper.findAppendixfileOne(uploadAppendixFile);
    }

    /**
     * 从mysql库中删除单个文件信息仅通过single_id
     * @param uploadAppendixFile uploadAppendixFile
     * @return int
     */
    @Override
    public int removeAppendixFileOneBySingleId(UploadAppendixFile uploadAppendixFile) {
        return uploadAppendixFileMapper.removeAppendixFileOneBySingleId(uploadAppendixFile);
    }

    /**
     * 司法所衔接选择失败后将之前上传的公安附件删除
     * @param priNum priNum
     * @param id id
     * @return int
     */
    @Override
    public int deleteUploadFile(String priNum,String id) {
        return uploadAppendixFileMapper.deleteUploadFile(priNum,id);
    }

    /**
     * 从mysql库中删除单个文件信息
     * @param uploadAppendixFile uploadAppendixFile
     */
    @Override
    public void removeAppendixFileOne(UploadAppendixFile uploadAppendixFile) {
        uploadAppendixFileMapper.removeAppendixFileOne(uploadAppendixFile);
    }
}